<template>
  <rx-layout>
    <div slot="center" style>
      <rx-fit>
        <div slot="toolheader" foldheader="true" foldbtn="true" border="false">
          <div class="table-page-search-wrapper">
            <a-form layout="inline">
              <a-row :gutter="24">
                <a-col :span="8">
                  <a-form-item :label="i18n('form.ureportName','报表名称')">
                    <a-input :placeholder="i18n('form.ureportName','报表名称','input')"/>
                  </a-form-item>
                </a-col>
                <template v-if="advanced">

                </template>
                <a-col :md="8" :sm="24">
              <span class="table-page-search-submitButtons">
                <a-button @click="$refs.table.loadData()" icon="search" type="primary">
                    {{$ti18('rxList.searchBtn','查询')}}
                </a-button>
                <a-button @click="resetSearchList" style="margin-left: 4px">
                    {{$ti18('rxList.resetBtn','重置')}}
                </a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px">
                  {{ advanced ? $ti18('rxList.putAwayBtn','收起') : $ti18('rxList.openBtn','展开' )}}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
                </a-col>
              </a-row>
            </a-form>
          </div>
          <div class="table-operator">
            <a-button v-if="allowEdit" type="primary" icon="plus" @click="addPrint">
                {{$ti18('rxList.newBtn',"新建")}}
            </a-button>
            <a-button v-if="allowEdit && editEnable && selectedRowKeys.length > 0" type="primary" icon="edit" @click="editOnePrint">
                {{$ti18('rxList.editBtn',"编辑")}}
            </a-button>
            <a-dropdown v-if="allowEdit && removeEnable && selectedRowKeys.length > 0">
              <a-button type="danger" icon="delete" @click="delByIds(selectedRowKeys)">
                  {{$ti18('rxList.delBtn','删除')}}
              </a-button>
            </a-dropdown>
          </div>
        </div>
        <rx-grid
          ref="table"
          :allowRowSelect="true"
          :multiSelect="true"
          :columns="columns"
          :defaultPageSize="10"
          url="/api-ureport/ureport2/core/ureportFile/query"
          :queryParam="queryParam"
          data-field="result.data"
          :pageSizeOptions="['10','30','40']"
          id-field="id"
          @selectChange="onSelectChange"
        >
          <span slot="action" slot-scope="{ text, record }" class="actionIcons">
            <span v-if="allowEdit && editEnable" @click.stop="editPrint(record)">
                {{$ti18('rxList.editBtn',"编辑")}}
            </span>
            <span v-if="allowEdit && removeEnable" @click.stop="delByIds([record.id])">
                {{$ti18('rxList.delBtn','删除')}}
            </span>
            <span v-if="!allowEdit" @click="selectPrint(record)">
                {{$ti18('rxList.select',"选择")}}
            </span>
          </span>
        </rx-grid>
      </rx-fit>
    </div>
  </rx-layout>
</template>

<script>
  import FormPrintLodopApi from '@/api/form/core/formPrintLodop'
  //import FormUreportList from './FormUreportList'
  import {BaseList, Util} from "@lowcode/jpaas-common-lib";
  export default {
    name: 'FormUreportList',
    mixins: [BaseList],
    props:["layerid","destroy","id","name","allowEdit"],
    data() {
      return {
        columns: [
          {
            title: this.$ti18('rxList.index','序号'),
            type: 'indexColumn',
            width: 100,
            dataIndex: 'serial',
            scopedSlots: {customRender: 'serial'}
          },
          {title: this.i18n('form.ureportName','报表名称'), dataIndex: 'name', width: 200},
          {title: this.$ti18('rxList.action','操作'), width: 100, dataIndex: 'action', scopedSlots: {customRender: 'action'}}
        ],
       /* component:FormPrintLodopEdit,*/
        comment: this.i18n('list.ureport',"报表打印模板"),
        widthHeight:['800px','600px']
      }
    },
    /*created() {
      this.queryParam['Q_FORM_ID__S_EQ'] = this.formId;
    },*/
    methods:{
      i18n(name,text,key){
          return this.$ti18(name,text,"printLodop",key);
      },
      boentI18n(name,text,key){
          return this.$ti18(name,text,"formBoEntity",key);
      },
      resetSearchList () {
        this.$nextTick(()=>{
          /*this.queryParam={Q_FORM_ID__S_EQ:this.formId};*/
            this.$refs[this.table].loadData();

        })
      },
      delById(ids){
        return FormPrintLodopApi.del({ ids: ids.join(',') });
      },
      getListByParams(parameter){
        return FormPrintLodopApi.query(parameter)
      },
      selectPrint(record){
        Util.closeWindow(this,"ok",record);
      },
      /*addPrint(){
        var self_ = this;
        var baseConf = {
          curVm: self_,
          component: this.component,
          title: "添加" + this.comment,
          max:true,
          data: {formId: self_.formId,formName:self_.formName,boDefId:self_.boDefId}
        };
        Util.open(baseConf, function (action) {
          if (action == "ok") {
            self_.refreshGrid();
          }
        });
      },*/
     /* editPrint(record){
        var conf={
          component:this.component,
          title:"编辑" + this.comment,
          max:true,
          data: {pkId:record.pkId,boDefId:this.boDefId}
        };
        this.handleEdit(conf);
      },*/
      editOnePrint(){
        var conf={
          component:this.component,
          title: this.$ti18('rxList.editBtn',"编辑") +this.comment,
          max:true
        };
        /*if(this.selectedRows.length>0){
          conf.data={pkId:this.selectedRows[0].pkId,boDefId:this.boDefId};
          this.handleEdit(conf)
        }*/
      }
    }
  }
</script>
<style scoped>

</style>

